package Lee_code;

public class Lee_67 {
    public static String addBinary(String a, String b)
    {
        int a_ten = cal_bin(a);
        int b_ten = cal_bin(b);
        System.out.println(a_ten);
        System.out.println(b_ten);
        String res = Integer.toBinaryString(a_ten + b_ten);
        return  res;
    }
    public static int cal_bin(String a)
    {
        int len = a.length();
        int num = 0;
        for(int i=0; i<len; i++)
        {
            //返回的是2的i次方
            num = num + Integer.parseInt(a.substring(i, i+1)) * (int)Math.pow(2, len-i-1);
        }
        return num;
    }
    public static void main(String[] args)
    {
        System.out.print(addBinary("1010", "1011"));

    }
}
